//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//   PACKAGE   : dcf
//   FILE      : Publisher.java
//   CLASS     : Publisher
//   DATE      : 2006-04-01
//   
//   DESCRIPTION
//   The Publisher class represents an endpoint the system that is a provider of a service.
//
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//   Copyright (c) 2006 by Hal Smith
//
//   Permission is hereby granted, free of charge, to any person obtaining a copy of this source code 
//   (the "Code")to deal with the Code without restriction, including without limitation the rights to use, copy,
//   modify, merge, publish and distribute the Code, and to permit persons to whom the Code is furnished to do 
//   so, subject to the following conditions:
//
//   The above copyright notice and this permission notice shall be included in all copies or substantial 
//   portions of the Software.
//   
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//   VERSION HISTORY
//
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

package dcf;


class Publisher extends Endpoint {

	// The name of the service the publisher provides.
	//
	private String serviceName;

	
	// Constructor.
	//
	// This operation initializes the publisher. The initHost parameter should be in the form or a numerical
	// IP address (i.e., "11.22.33.44"), initPort must be between 0 and 65535, and the service name must not 
	// be null. If any of the parameters are invalid, this operation will throw an InitializationException. 
	// There are no other exceptions thrown by this operation.
	//
	public Publisher(String initHost, int initPort, String initServiceName) throws InitializationException {
		
		// Set the endpoint information.
		//
		super (initHost, initPort);
		
		if (initServiceName == null) {

			System.out.println("Publisher.Publisher(initEndpoint, initServiceName):");
			System.out.println("   Service name cannot be null.");
			
			throw new InitializationException();

		} else {
			
			serviceName = initServiceName;
		
		}
	
	} // constructor
	
	
	
	// This operation returns the name of the service provided by the publisher. There are no exceptions thrown
	// by this operation.
	//
	public String getServiceName()	{
	
		return serviceName;
	
	} // getServiceName()


	// This operation returns true if the supplied object logically represents the same publisher as the this, 
	// and false otherwise.
	//
	public boolean equals(Object obj) {
		
		if (obj instanceof Publisher) {
		   
		   Publisher rhs = (Publisher)obj;
		   
		   return ( (super.equals(rhs)) && (serviceName.equals(rhs.serviceName)) );
		
		} else {
			
			return false;
		}

	}
	
} // Publisher
